import axios from 'axios'
import qs from 'qs'


const Axios = axios.create();

Axios.defaults.baseURL ='http://dev.mumway.com/index/activity/';



Axios.interceptors.request.use(
	config => {
    if (!config.data) {
     config.data = {}
   }
   
  return config;
},
error => {
  console.log(error)

  return Promise.reject(error.data.error.message);
}
);


Axios.interceptors.response.use(
	res => {
    if (res.status == 200) {
     if (res.data.code == -1) {
      console.log(res.data.msg)
    }
    return res.data;
  }
},
error => {
 console.log(error)
 return Promise.reject(error);
}
);

// 对axios的实例重新封装成一个plugin ,方便 Vue.use(xxxx)
export default {
	install: function(Vue, Option) {
		Object.defineProperty(Vue.prototype, "$http", { value: Axios });
	},
  Axios:Axios
};